package comm;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class CacheUtil {
    public static Cache<String, String> cache;
    public static void init() {
        cache = CacheBuilder.newBuilder()
                .maximumSize(2)
                .expireAfterAccess(5, TimeUnit.SECONDS)
                .build();
    }

    public static Cache<String, String> getCache() {
        if (cache == null) {
            init();
        }
        return cache;
    }
}
